const { defineConfig } = require('@vue/cli-service');

const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');

const cesiumSource = './node_modules/cesium/Source';
const cesiumWorkers = '../Build/Cesium/Workers';

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  configureWebpack: {
    plugins: [
      new CopyWebpackPlugin({
        patterns: [{
          from: path.join(cesiumSource, cesiumWorkers),
          to: 'Workers',
        }],
      }),
      new CopyWebpackPlugin({
        patterns: [{
          from: path.join(cesiumSource, 'Assets'),
          to: 'Assets',
        }],
      }),
      new CopyWebpackPlugin({
        patterns: [{
          from: path.join(cesiumSource, 'Widgets'),
          to: 'Widgets',
        }],
      }),
      new CopyWebpackPlugin({
        patterns: [{
          from: path.join(cesiumSource, 'ThirdParty/Workers'),
          to: 'ThirdParty/Workers',
        }],
      }),
      new webpack.DefinePlugin({
        CESIUM_BASE_URL: JSON.stringify('./'),
      }),
      new NodePolyfillPlugin(),
    ],
    resolve: {
      alias: {
        cesium: path.resolve(__dirname, cesiumSource),
      },
    },
  },

});
